package cn.edu.scau.cmi.huxiantao.composite.safe;

import java.util.HashSet;
import java.util.Set;

public class SafeOrganization implements SafeComponent{
	
	private Set<SafeComponent> children;
	private String name;
	
	public SafeOrganization(String name) {
		this.name=name;
		children=new HashSet<SafeComponent>();
	}
	
	@Override
	public String doSomething() {
		String result="安全组织:"+name+"{\n";
		for(SafeComponent component:children) {
			result+=component.doSomething();
		}
		result+="}\n";
		return result;
	}
	@Override
	public String getName() {
		return this.name;
	}
	
	public void addChild(SafeComponent child) {
		children.add(child);
	}

	public void deleteChild(SafeComponent child) {
		children.remove(child);
	}
	
	public Set<SafeComponent> getChildren() {
		return this.children;
	}
	
	public void updateChildren(Set<SafeComponent> children) {
		this.children=children;
	}
}
